package com.ss.android.article.base.ui;

import android.content.Context;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.browser.R;

public final class NoNetView extends LinearLayout {
    public TextView mBtnNoDataAction;
    private View mNoDataView;
    private ImageView mIvNoDataImage;
    private TextView mTvNoDataTipBig;
    private TextView mTvNoDataTipSmall;
    private int f;

    public NoNetView(Context arg3) {
        super(arg3);
        this.mNoDataView = LayoutInflater.from(arg3).inflate(com.ss.android.article.browser.R.layout.no_data_view, this);
        this.mIvNoDataImage = this.mNoDataView.findViewById(com.ss.android.article.browser.R.id.iv_no_data_img);
        this.mTvNoDataTipBig = this.mNoDataView.findViewById(com.ss.android.article.browser.R.id.tv_no_data_tip_big);
        this.mTvNoDataTipSmall = this.mNoDataView.findViewById(com.ss.android.article.browser.R.id.tv_no_data_tip_small);
        this.mBtnNoDataAction = this.mNoDataView.findViewById(com.ss.android.article.browser.R.id.btn_no_data_action);
    }

    public final void initNoDataActionBtn() {
        if(this.mBtnNoDataAction != null) {
            Resources resources = this.getResources();
            com.ss.android.j.b.isNightModeToggled();
            mBtnNoDataAction.setTextColor(resources.getColorStateList(com.ss.android.article.browser.R.color.tv_no_data_action));
            com.ss.android.j.b.isNightModeToggled();
            UIUtils.setBackgroundResource(mBtnNoDataAction, R.drawable.btn_no_data_action);
        }
    }

    public final void b() {
        this.mIvNoDataImage.setBackgroundResource(0);
    }

    public final void setButtonOption(ab arg4) {
        if(arg4 == null) {
            this.mBtnNoDataAction.setVisibility(View.GONE);
        }
        else {
            aa v0 = arg4.a;
            if(v0 != null) {
                this.mBtnNoDataAction.setOnClickListener(v0.a);
                this.mBtnNoDataAction.setText(v0.b);
                this.mBtnNoDataAction.setVisibility(View.VISIBLE);
                if(arg4.b >= 0) {
                    ViewGroup.LayoutParams v0_1 = this.mBtnNoDataAction.getLayoutParams();
                    ((LinearLayout.LayoutParams)v0_1).topMargin = arg4.b;
                    this.mBtnNoDataAction.setLayoutParams(v0_1);
                }
            }
        }
    }

    public final void setImgOption(ac arg4) {
        if(arg4 != null) {
            switch(z.a[arg4.a.ordinal()]) {
                case 1: {
                    this.f = R.drawable.fo;
                    break;
                }
                case 2: {
                    this.f = R.drawable.delete_article_loading;
                    break;
                }
                case 3: {
                    this.f = R.drawable.fm;
                    break;
                }
                case 4: {
                    this.f = R.drawable.fn;
                    break;
                }
            }

            this.mIvNoDataImage.setImageResource(this.f);
            ViewGroup.LayoutParams v0 = this.mIvNoDataImage.getLayoutParams();
            if(arg4.b >= 0) {
                ((LinearLayout.LayoutParams)v0).setMargins(0, arg4.b, 0, 0);
            }

            if(arg4.c > 0 && arg4.d > 0) {
                ((LinearLayout.LayoutParams)v0).height = arg4.c;
                ((LinearLayout.LayoutParams)v0).width = arg4.d;
            }

            this.mIvNoDataImage.setLayoutParams(v0);
        }
    }

    public final void setTextOption(ad arg6) {
        CharSequence v4 = null;
        int v3 = GONE;
        if(arg6 != null) {
            if(!TextUtils.isEmpty(arg6.a)) {
                this.mTvNoDataTipBig.setText(arg6.a);
                this.mTvNoDataTipBig.setVisibility(View.VISIBLE);
            }
            else {
                this.mTvNoDataTipBig.setVisibility(v3);
            }

            if(!TextUtils.isEmpty(v4)) {
                this.mTvNoDataTipSmall.setText(v4);
                this.mTvNoDataTipSmall.setVisibility(View.VISIBLE);
                return;
            }

            this.mTvNoDataTipSmall.setVisibility(v3);
        }
    }
}

